<template>
  <up-card title="常用功能">
    <template #body>
      <view class="menu-box" v-if="false">
        <view class="item" @tap="toPage(1)">
          <view class="image-box">
            <image class="image" src="/static/images/top-up.png"></image>
          </view>
          <view class="title">充值</view>
        </view>
        <view class="item" @tap="toPage(2)">
          <view class="image-box">
            <image class="image" src="/static/images/withdraw.png"></image>
          </view>
          <view class="title">提现</view>
        </view>
        <view class="item" @tap="toPage(3)">
          <view class="image-box">
            <image class="image" src="/static/images/transtion.png"></image>
          </view>
          <view class="title">互转</view>
        </view>
        <view class="item" @tap="openInvitation()">
          <view class="image-box">
            <image class="image" src="/static/images/transtion.png"></image>
          </view>
          <view class="title">邀请码</view>
        </view>
        <view class="item" @tap="toPage(4)">
          <view class="image-box">
            <image class="image" src="/static/images/transtion.png"></image>
          </view>
          <view class="title">申请代理商</view>
        </view>
      </view>

      <up-cell-group>
        <up-cell title="充值" isLink @tap="toPage(1)"/>
        <up-cell title="提现" isLink @tap="toPage(2)"></up-cell>
        <up-cell title="互转" isLink @tap="toPage(3)"></up-cell>
        <up-cell title="邀请码" isLink @tap="openInvitation()"></up-cell>
        <up-cell v-if="dataInfo.ievel===UserTypeEnum.user.value"
                 title="申请代理商" isLink @tap="toPage(4)"></up-cell>
        <template v-if="dataInfo.ievel===UserTypeEnum.agent.value">
          <up-cell title="区域用户" isLink @tap="toPage(6)"></up-cell>
          <up-cell title="广告" isLink @tap="toPage(7)"></up-cell>
        </template>
        <up-cell title="用户协议" isLink @tap="toPage(5)"></up-cell>
        <up-cell title="隐私政策" isLink @tap="toPage(5)"></up-cell>

      </up-cell-group>
    </template>
  </up-card>


</template>
<script setup>

import {UserTypeEnum, WorkStatusEnum} from "@/enums/user";

const emits = defineEmits(['openInvitation', 'success'])
const props = defineProps({
  dataInfo: {
    type: Object,
    default: () => {
      return {}
    }
  }
})
const toPage = (type) => {
  const data = {
    1: '/pages/my/balanceTopup/index',
    2: '/pages/my/withdraw/index',
    3: '/pages/my/accountTransfer/index',
    4: '/pages/my/agent/index?content=yhxy',
    5: '/pages/my/agreement/index?content=yszc',
    6: '/pages/my/regionalUsers/index',
    7: '/pages/my/advertisement/index',
  }

  if (type === 4) {
    uni.$on('agentSuccess', () => {
      emits('success')
    })
  }
  qly.page.open(data[type])
}

const openInvitation = () => {
  emits('openInvitation')
}
</script>
<style scoped lang="scss">
.menu-box {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32rpx 12rpx;

  .item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #606266;

    .image-box {
      width: 60rpx;
      height: 60rpx;
      margin-bottom: 12rpx;
      border-radius: 8rpx;
      overflow: hidden;

      .image {
        width: 100%;
        height: 100%;
      }
    }

  }
}


</style>
